//
//  DBHelper.h
//  KidReading
//
//  Created by telen on 15/7/20.
//  Copyright (c) 2015年 刘赞黄Telen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "JRFMDB.h"

@interface TABLE_base : NSObject
+ (instancetype)instance;
+ (NSString*)primaryKey;
- (NSString*)byPrimaryKey;
- (NSString*)countByPrimaryKey;
+ (NSString*)tableName;
+ (NSString*)updateTable;//sq;
+ (NSString*)createTable;//sql
- (NSDictionary*)replaceRecord;
- (NSDictionary*)updateRecord_FromServer;
//
+ (NSDictionary*)replacedKeyFromPropertyName;
//
@end

#pragma mark- DBHelper
@interface DBHelper : NSObject
+ (instancetype)shareInstance;

- (BOOL)dbFile_initForDBPath:(NSString*)dbPath; //YES 表示初始化了，NO表示已经存在或copy失败
- (NSString*)getDBPath:(NSString *)dbNameKey debugPath:(NSString *)dbNameUnkey_debug dbKey:(NSString*)dbkey dbebug:(BOOL)debug;

- (NSArray* )getList_fromTableClass:(NSString *)tableClassName where:(NSString *)sql db:(JRFMDatabase *)db;
- (NSArray* )getDictList_fromTableClass:(NSString *)tableClassName where:(NSString *)sql db:(JRFMDatabase *)db;

- (void)updateListToTableClass:(NSString *)tableClassName dictArr:(NSArray*)dictList db:(JRFMDatabase *)db;
- (void)update_Only_ListToTableClass:(NSString *)tableClassName dictArr:(NSArray*)dictList db:(JRFMDatabase *)db;
- (void)replaceListToTableClass:(NSString *)tableClassName dictArr:(NSArray*)dictList db:(JRFMDatabase *)db;
- (void)deletListToTableClass:(NSString *)tableClassName dictArr:(NSArray*)dictList db:(JRFMDatabase *)db;
- (void)deletListToTableClass:(NSString *)tableClassName tbArr:(NSArray*)dictList db:(JRFMDatabase *)db;

@end
